package com.bos.mapper;

import com.bos.data.model.BosCustomerModel;
import com.bos.data.model.BosParamModel;
import com.bos.data.model.BosProjectModel;
import com.bos.data.model.BosUserModel;
import org.apache.ibatis.annotations.*;

import java.util.List;


public interface ProjectMapper {
    //1。查询出Project表中的所有数据(根据名字)
    @Select("select * from bos_project where leader=#{leader}")
    public List<BosProjectModel> findProjects(String name);

    //1.查询出所有数据
    @Select("select * from bos_project")
    public List<BosProjectModel> findProject();

    //------------插入操作----------------
    //2.往Project表中插入数据
    @Insert("insert into bos_project(wType,wName,sTime,eTime,progess,pdetail,leader,groups,checker,kehuer,remarks) values(#{wType},#{wName},#{sTime},#{eTime},#{progess},#{pdetail},#{leader},#{groups},#{checker},#{kehuer},#{remarks})")
    public int insertProject(BosProjectModel project);

    //3.往Project表中插入数据
    @Insert("insert into bos_project(wType,wName,sTime,eTime,progess,pdetail,leader,groups,checker,kehuer,others1,others2,remarks) values(#{wType},#{wName},#{sTime},#{eTime},#{progess},#{pdetail},#{leader},#{groups},#{checker},#{kehuer},#{others1},#{others2},#{remarks})")
    public int insertProject2(BosProjectModel project);

    //------------修改操作----------------
    //4.根据id修改有其他1和其他2的数据
    @Update("update bos_project set groups=#{groups},progess=#{progess},wType=#{wType},wName=#{wName},sTime=#{sTime},eTime=#{eTime},pdetail=#{pdetail},leader=#{leader},checker=#{checker},kehuer=#{kehuer},others1=#{others1},others2=#{others2},remarks=#{remarks} where id=#{id}")
    public int updateById(BosProjectModel pro);

    //5.根据id修改没有其他1和其他2的数据
    @Update("update bos_project set wType=#{wType},wName=#{wName},sTime=#{sTime},progess=#{progess},pdetail=#{pdetail},leader=#{leader},groups=#{groups},checker=#{checker},kehuer=#{kehuer},remarks=#{remarks} where id=#{id}")
    public int updateById2(BosProjectModel pro);

    //6.根据id修改没有开始时间也没有结束时间的数据
    @Update("update bos_project set wType=#{wType},wName=#{wName},progess=#{progess},pdetail=#{pdetail},leader=#{leader} where id=#{id}")
    public int updateById3(BosProjectModel pro);

    //7.根据id查询出表中的数据
    @Select("select * from bos_project where id=#{id}")
    public BosProjectModel findProjectById(int id);

    //10.根据序号，工作类型，项目名称，开始时间，完成时间，项目进度，项目情况，负责人进行查询出结果
    @SelectProvider(method = "findStudent", type = ProjectProvider.class)
    public List<BosProjectModel> selectByWhere(String where, String[] shuigou, String[] wtype, String[] pteam, String[] pleader);

    //11.根据id删除所选的数据
    @Delete("delete from bos_project where id=#{id}")
    public int deleteById(int id);

    //12.查询出用户表中的数据
    @Select("select * from bos_user")
    public List<BosUserModel> findUsers();

    //13根据传过来的数据去修改bos_project表中的leader
    @Update("update bos_project set leader=#{leader} where id=#{id}")
    public int updateLeader(BosProjectModel project);

    //14.根据项目表的bid查询客户表中的数据
    @Select("select * from bos_customer where cname=#{cname}")
    public BosCustomerModel findCustomerByCname(String cname);

    //15.根据typeName为项目进度查询出数据
    @Select("select * from bos_param where typeName=#{typeName}")
    public List<BosParamModel> findBos_params(String typeName);
    //16.查询出去除重复数据的项目负责人
    @Select("select DISTINCT leader from bos_project")
    public List<BosProjectModel> findLeaders();

}
